<html>
<body>

<div>
    <input id="code" placeholder="验证码" type="text" class=""
           style="width:170px">
    <!-- 验证码 显示 -->
    <img onclick="javascript:getvCode()" id="verifyimg" style="margin-left: 20px;"/>
</div>

<script type="text/javascript">
    getvCode();

    /**
     * 获取验证码
     * 将验证码写到login.html页面的id = verifyimg 的地方
     */
    function getvCode() {
        document.getElementById("verifyimg").src = timestamp("http://127.0.0.1:81/verifyCode");
    }
    //为url添加时间戳
    function timestamp(url) {
        var getTimestamp = new Date().getTime();
        if (url.indexOf("?") > -1) {
            url = url + "&timestamp=" + getTimestamp
        } else {
            url = url + "?timestamp=" + getTimestamp
        }
        return url;
    };


</script>
</body>

</html>